//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.neurosky.thinkgear;

public class SGFilter {
    private int a;
    private int b;
    private int c;
    private int d;
    private float[][] e;
    private float[] f;

    public SGFilter() {
    }

    public float[] filterData(float[] var1, int var2, int var3) {
        this.a = var3;
        this.b = var2;
        this.c = (this.b - 1) / 2;
        this.e = new float[this.b][this.b];
        float[][] var10002 = this.e;
        SGFilter var14 = this;
        float[][] var15 = new float[this.a + 1][this.a + 1];
        float[][] var4 = new float[this.b][this.a + 1];
        float[][] var5 = new float[this.b][this.a + 1];
        float[][] var6 = new float[this.b][this.b];

        int var7;
        int var8;
        for(var7 = -this.c; var7 <= var14.c; ++var7) {
            for(var8 = 0; var8 <= var14.a; ++var8) {
                var4[var7 + var14.c][var8] = (float)Math.pow((double)var7, (double)var8);
            }
        }

        int var9;
        for(var7 = 0; var7 <= var14.a; ++var7) {
            for(var8 = 0; var8 <= var14.a; ++var8) {
                for(var9 = 0; var9 < var14.b; ++var9) {
                    var15[var7][var8] += var4[var9][var8] * var4[var9][var7];
                }
            }
        }

        var8 = var14.a + 1;
        float[][] var17 = var15;
        SGFilter var16 = var14;
        float[][] var18 = new float[var8][var8];
        float var10 = (float)(1.0D / (double)var14.a(var15, var8));
        float[][] var11 = new float[var8 - 1][var8 - 1];

        for(int var12 = 0; var12 < var8; ++var12) {
            for(int var13 = 0; var13 < var8; ++var13) {
                a(var17, var11, var12, var13, var8);
                var18[var13][var12] = var10 * var16.a(var11, var8 - 1);
                if((var13 + var12) % 2 == 1) {
                    var18[var13][var12] = -var18[var13][var12];
                }
            }
        }

        var17 = var18;

        for(var8 = 0; var8 <= var14.a; ++var8) {
            for(var9 = 0; var9 < var14.b; ++var9) {
                for(var3 = 0; var3 <= var14.a; ++var3) {
                    var5[var9][var8] += var4[var9][var3] * var17[var3][var8];
                }
            }
        }

        for(var8 = 0; var8 < var14.b; ++var8) {
            for(var9 = 0; var9 < var14.b; ++var9) {
                for(var3 = 0; var3 <= var14.a; ++var3) {
                    var6[var8][var9] += var5[var8][var3] * var4[var9][var3];
                }
            }
        }

        this.e = var6;
        this.d = var1.length;
        this.f = new float[this.d];

        for(var2 = 0; var2 <= this.c; ++var2) {
            for(var3 = 0; var3 < this.b; ++var3) {
                this.f[var2] += this.e[var2][var3] * var1[var3];
            }
        }

        for(var2 = this.c + 1; var2 <= this.d - this.c - 2; ++var2) {
            for(var3 = 0; var3 < this.b; ++var3) {
                this.f[var2] += this.e[this.c][var3] * var1[var2 - this.c + var3];
            }
        }

        for(var2 = 0; var2 <= this.c; ++var2) {
            for(var3 = 0; var3 < this.b; ++var3) {
                this.f[this.d - this.c + var2 - 1] += this.e[this.c + var2][var3] * var1[this.d - this.b + var3];
            }
        }

        return this.f;
    }

    private static int a(float[][] var0, float[][] var1, int var2, int var3, int var4) {
        boolean var5 = false;
        int var6 = 0;

        for(int var7 = 0; var7 < var4; ++var7) {
            if(var7 != var2) {
                int var9 = 0;

                for(int var8 = 0; var8 < var4; ++var8) {
                    if(var8 != var3) {
                        var1[var6][var9] = var0[var7][var8];
                        ++var9;
                    }
                }

                ++var6;
            }
        }

        return 1;
    }

    private float a(float[][] var1, int var2) {
        if(var2 == 1) {
            return var1[0][0];
        } else {
            float var3 = 0.0F;
            float[][] var4 = new float[var2 - 1][var2 - 1];

            for(int var5 = 0; var5 < var2; ++var5) {
                a(var1, var4, 0, var5, var2);
                var3 = (float)((double)var3 + (var5 % 2 == 1?-1.0D:1.0D) * (double)var1[0][var5] * (double)this.a(var4, var2 - 1));
            }

            return var3;
        }
    }
}
